using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Wlmy.Ids4.Model;
using Wlmy.Ids4.Model.Dto.CommonOutput;
using Wlmy.Ids4.Model.Dto.User;
using Wlmy.Ids4.Services;

namespace Wlmy.Ids4.Controllers
{
    public class UserController : ApiBaseController
    {
        private readonly UserManager<User> _userManager;
        private readonly IUserServices _userServices;

        public UserController(UserManager<User> userManager, IUserServices userServices)
        {
            _userManager = userManager;
            _userServices = userServices;
        }
        [HttpPost]
        public async Task CreateUser(CreateUserInput input)
        {
            var user = _mapper.Map<User>(input);
            await _userManager.CreateAsync(user, input.PassWord);
        }
        [HttpGet]
        public async Task<PageRequestOutput<GetUserListOutput>> GetUserList([FromQuery]GetUserListInput input)
        {
           return await _userServices.GetUserList(input);
        }
    }
}
